import Vue from 'vue'
import App from './App'
import store from './store'
import '@/static/scss/common.scss';

// 引入全局样式
import './static/css/global.css';

Vue.config.productionTip = false
App.mpType = 'app'
Vue.prototype.$store = store

/* 全局挂载请求库(GraceUI) */
import GraceRequest from './GraceUI5/js/request/request.js'
uni.gRequest = GraceRequest;

/* 全局挂载请求库(GraceUI封装) */
import apiRequest from './api/apiRequest.js'
Vue.prototype.$request = apiRequest;

/* 全局挂载工具类 */
import utils from "@/static/utils/index.js"; 
Vue.prototype.$utils = utils;

/* 全局常量 */
import constant from "@/static/utils/constant.js";
Vue.prototype.$const = constant;

// 全局过滤器
Vue.filter('dateFormat', (timestamp, format = 'YYYY-MM-DD HH:mm:ss') => {
    if (!timestamp) return '';
    
    const date = new Date(timestamp);
    const year = date.getFullYear();
    const month = (date.getMonth() + 1).toString().padStart(2, '0');
    const day = date.getDate().toString().padStart(2, '0');
    const hours = date.getHours().toString().padStart(2, '0');
    const minutes = date.getMinutes().toString().padStart(2, '0');
    const seconds = date.getSeconds().toString().padStart(2, '0');
    
    return format
        .replace('YYYY', year)
        .replace('MM', month)
        .replace('DD', day)
        .replace('HH', hours)
        .replace('mm', minutes)
        .replace('ss', seconds);
});

const app = new Vue({
	store,
    ...App
})
app.$mount()